package com.tqfframe.common.exception;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;

/**
 * @Author: 唐祺峰
 * @Date: 2022/2/8 0008 11:17
 * @Version 1.0
 */
public class BaseException extends RuntimeException {

    public Integer code;

    public String message;

    private HttpStatus httpStatus;

    public BaseException(Integer code,String message,HttpStatus httpStatus){
        super();
        this.code=code;
        this.message=message;
        this.httpStatus = httpStatus == null ? this.chooseHttpStatus() : httpStatus;
    }

    public HttpStatus chooseHttpStatus() {
        HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR;
        if (this.getHttpStatus() != null) {
            return this.getHttpStatus();
        }
        return status;
    }
    public HttpStatus getHttpStatus() {
        return httpStatus;
    }
}

